package com.itheima.info.manage.service;

import com.itheima.info.manage.dao.StudentDao;
import com.itheima.info.manage.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author Yao
 * @date 2020/6/20 0020
 **/
public class StudentService {

    private StudentDao studentDao=new StudentDao();

    public void addStudent(Student student) {
        studentDao.addStudent(student);
    }

    public int getIndex(String sid) {
        return studentDao.getIndex(sid);
    }

    public ArrayList<Student> queryStudents() {
        ArrayList<Student> list = studentDao.queryStudents();
        boolean flag=false;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i)!=null){
                flag=true;
                break;
                //跳出
            }
        }
        if (flag){
            return list;
        }else {
            return null;
        }

    }

    public void deleteStudent(int index) {
        studentDao.deleteStudent(index);
    }

    public void updateStudent(Student stu) {
        studentDao.updateStudent(stu);
    }

}
